package net.pimpas.report.processor.condition.impl;

import net.pimpas.report.processor.condition.AbstractCondition;
import net.pimpas.report.processor.condition.ConditionType;
import net.pimpas.report.processor.exception.ConditionException;
import net.pimpas.report.processor.field.Field;
import net.pimpas.report.processor.resolver.FieldPropertyResolver;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

public class BetweenCondition extends AbstractCondition {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8296506812533605736L;
	private Object value1;
	private Object value2;
	
	
	public BetweenCondition(Field field, Object value1, Object value2) {
		super(field, ConditionType.BETWEEN);
		this.setValue1(value1);
		this.setValue2(value2);
	}

	@Override
	public Criterion process(String fieldAlias, FieldPropertyResolver resolver) throws ConditionException {
		return Restrictions.between(fieldAlias, this.getValue1(), this.getValue2());
	}

	public Object getValue1() {
		return value1;
	}

	public void setValue1(Object value1) {
		this.value1 = value1;
	}

	public Object getValue2() {
		return value2;
	}

	public void setValue2(Object value2) {
		this.value2 = value2;
	}
}